package base

import (
	"fmt"
)

func GoBase() {
	fmt.Println("welcome to 唱跳,rap,篮球!")
	//变量:定义一个空变量
	//var name string
	//var sex, favorite string
	//var (
	//	wight  int
	//	height int
	//)
	//var name string = "张三"
	//var sex, favorite string = "男", "唱跳rap篮球"
	//var (
	//	wight  int = 100
	//	height int = 100
	//)
	name := "张三"
	sex, favorite := "女", "唱跳rap篮球"
	wight, height := 100, 180
	fmt.Println(name)
	fmt.Println(sex, favorite)
	fmt.Println(wight, height)

}

// 加法
func SumInt(a, b int) int {
	return a + b
}

var (
	result int
)

// 指针封装
func Subtraction_1(a, b int, algorithm *string) int {
	if algorithm == nil || *algorithm == "" {
		algorithm = new(string)
		*algorithm = "+"
	}
	if *algorithm == "-" {
		return a - b
	}
	if *algorithm == "+" {
		return a + b
	}
	if *algorithm == "*" {
		return a * b
	}
	if *algorithm == "/" {
		return a / b
	}
	return 0
}

// 参数结构体封装
type FistValue struct {
	Value int
}

func (f *FistValue) Add(append int) int {
	f.Value += append
	fmt.Println(f.Value)
	return f.Value
}

func (f *FistValue) Subtraction(append int) int {
	f.Value -= append
	fmt.Println(f.Value)
	return f.Value
}

func (f *FistValue) Multiply(append int) int {
	if append == 0 {
		fmt.Println("append is zero,func not meaning!")
		return 0
	}
	f.Value *= append
	fmt.Println(f.Value)
	return f.Value
}

func (f *FistValue) Divide(append int) int {
	if append == 0 {
		fmt.Println("append is zero,func not meaning!")
		return 0
	}
	f.Value /= append
	fmt.Println(f.Value)
	return f.Value
}
